import java.util.Scanner;

/**
 * @Author YuanYuan
 * @Date 2022/4/23
 * @Time 19:09
 */
public class TestDemo {
    public static int qinJiuSao(int a, int b) {
        while(a!=b) {
            if(a>b) {
                a -= b;
            }else {
                b -= a;
            }
        }
        return b;
    }
    public static int eucild(int a, int b) {
        while(a%b!=0) {
            int c = a%b;
            a = b;
            b = c;
        }
        return b;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num1 = scanner.nextInt();
        int num2 = scanner.nextInt();
        int ret1 = qinJiuSao(num1,num2);
        System.out.println(ret1);
        int ret2 = eucild(num1,num2);
        System.out.println(ret2);
    }
}
